package com.lesama.map;

/*
    Map集合：
        TreeMap: 键排序， 键是红黑树
        HashMap: 键唯一，需要重写键的equals和hashCode方法。键是哈希表
        LinkedHashMap: 键唯一，且保证存取顺序， 键是哈希表+双向链表
 */

import com.lesama.domain.Student;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.TreeMap;

public class MapDemo2 {
    public static void main(String[] args) {
        TreeMap<Student, String> treeMap = new TreeMap<>();
        treeMap.put(new Student("lyl", 23), "广东");
        treeMap.put(new Student("xixi", 16), "今州");
        treeMap.put(new Student("feibi", 26), "黎娜西塔");
        treeMap.put(new Student("chun", 18), "黑海岸");
        System.out.println(treeMap);

        System.out.println("------------------------");

        HashMap<Student, String> hashMap = new HashMap<>();
        hashMap.put(new Student("lyl", 23), "广东");
        hashMap.put(new Student("xixi", 16), "今州");
        hashMap.put(new Student("feibi", 26), "黎娜西塔");
        hashMap.put(new Student("chun", 18), "黑海岸");
        System.out.println(hashMap);

        System.out.println("------------------------");

        LinkedHashMap<Student, String> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put(new Student("lyl", 23), "广东");
        linkedHashMap.put(new Student("xixi", 16), "今州");
        linkedHashMap.put(new Student("feibi", 26), "黎娜西塔");
        linkedHashMap.put(new Student("chun", 18), "黑海岸");
        System.out.println(linkedHashMap);
    }
}